import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class z2 {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        StringBuilder s = new StringBuilder(sc.next());
        int t = sc.nextInt();
        ty[] a = new ty[t + 1];
        for(int i = 1; i <= t; ++ i ) {
            int op ,wz = 0;
            String x = "";
            op = sc.nextInt();
            if(op == 1) {
                wz = sc.nextInt();
                x = sc.next();
            }
            if(op == 1)
            a[i] = new ty(op, wz, x.charAt(0));
            else a[i] = new ty(op, 1, '1');
        }
        int j = 0;
        int flag = 0;
        for(int i = t; i >= 1; -- i) {
            if(a[i].op == 2 || a[i].op == 3) {
                if(a[i].op == 2) {
                    flag = 2;//变为小写
                } else {
                    flag = 3;//变为大写
                }
                j = i;
                break;
            }
        }
        for(int i = 1; i <= j; ++ i ) {
            if(a[i].op == 1) {
                s.setCharAt(a[i].wz - 1, a[i].x);
            }
        }
        if(flag == 3) {//转大写
            for(int i = 0; i < s.length(); ++ i ) {
                if(s.charAt(i) >= 'a' && s.charAt(i) <= 'z') {
                    s.setCharAt(i, (char) (s.charAt(i) - 32));
                }
            }
        } if(flag == 2) {
            for(int i = 0; i < s.length(); ++ i ) {
                if(s.charAt(i) >= 'A' && s.charAt(i) <= 'Z') {
                    s.setCharAt(i, (char) (s.charAt(i) + 32));
                }
            }
        }
        for(int i = j + 1; i <= t; ++ i ) {
            s.setCharAt(a[i].wz - 1, a[i].x);
        }
        FileOutputStream fos = new FileOutputStream("D:\\杂论\\6.out");
        fos.write(s.toString().getBytes(StandardCharsets.UTF_8));
       // System.out.println(s);
    }
}
class ty {
    int op, wz;
    char x;
    public ty(int op, int wz, char x) {
        this.op = op;
        this.wz = wz;
        this.x = x;
    }
}
